#ifndef _AI_SPEECH_RECOGNITION_HEAD_H
#define _AI_SPEECH_RECOGNITION_HEAD_H

#include "snowboy-detect.h"
#include <iostream>
#include "linux-alsa-sound.h"
#include <thread>
#include "baidu-ai-asr.h"

using namespace std;

class AISpeechRecognition
{
public:
	AISpeechRecognition(const string &audioDevice = "plughw:0,0");
	bool start(void);
	void stop(void);
	void aiAudioThreadRun(void);
	void recognitionUserSpeechData(void);
	void playAckAudio(void);

	static void handleTimeOut(int signum);

private:
	static bool             wakeState;
	BaiduAiAsr *            barc;
	string                  accessToken;
	bool                    aiThreadRunFlag;
	thread *                aiThread;
	snowboy::SnowboyVad *   vad;
	snowboy::SnowboyDetect *detect;
	LinuxAlsaSound          alsaSound;
	string                  audioDevice;
	vector<uint8_t>         userSpeechData;
};

#endif